import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KpiMasterVO, KpiMasterForm, KpiMasterQuery, KpiMasterGroup } from '@/api/manu/kpiMaster/types';

/**
 * 查询主数据列表
 * @param query
 * @returns {*}
 */

export const listKpiMaster = (query?: KpiMasterQuery): AxiosPromise<KpiMasterVO[]> => {
  return request({
    url: '/manu/kpiMaster/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询主数据详细
 * @param id
 */
export const getKpiMaster = (id: string | number): AxiosPromise<KpiMasterVO> => {
  return request({
    url: '/manu/kpiMaster/' + id,
    method: 'get'
  });
};

/**
 * 新增主数据
 * @param data
 */
export const addKpiMaster = (data: KpiMasterForm) => {
  return request({
    url: '/manu/kpiMaster',
    method: 'post',
    data: data
  });
};

/**
 * 修改主数据
 * @param data
 */
export const updateKpiMaster = (data: KpiMasterForm) => {
  return request({
    url: '/manu/kpiMaster',
    method: 'put',
    data: data
  });
};

/**
 * 删除主数据
 * @param id
 */
export const delKpiMaster = (id: string | number | Array<string | number>) => {
  return request({
    url: '/manu/kpiMaster/' + id,
    method: 'delete'
  });
};

export const generateRecordByYear = (year: number) => {
  return request({
    url: '/manu/kpiMaster/generateAllByYear/' + year,
    method: 'get'
  });
}
